package Chapter2.Comparing.c6;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;

public class ListDemo3 {


    public static void main(String[] args) {
        ArrayList<User> users = new ArrayList<>();
        User user2 = new User("Jack",22);
        User user3 = new User("Jack",23);
        User user4 = new User("Jim",11);

        users.add(new User("Tim",18));
        users.add(new User("Tom",20));
        users.add(user2);
        users.add(user2);
        users.add(user2);
        users.add(user2);
        users.add(user4);

        for (int i=0; i<users.size(); i++) {
            User user1= users.get(i);
            System.out.println(user1.toString());
        }

        ArrayList<User> userss = new ArrayList<>();
        userss.add(new User("Tim",18));
        userss.add(new User("Tom",20));

        System.out.println(user2.equals(user3));
        System.out.println(users.contains(user2));
        System.out.println(users.indexOf(user2));
        System.out.println(users.lastIndexOf(user2));
        System.out.println(users.containsAll(userss));


        /*users.sort(new Comparator<User>() {
            @Override
            public int compare(User o1, User o2) {
                return o2.getAge() - o1.getAge();
            }
        });*/
        /*Collections.sort(users);
        System.out.println("-----------------------------");
        for (User u:users) {
            System.out.println(u);
        }*/



    }


}
